#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1000;
int n, Q;
int a[N][N]; int b[N][N]; int c[N][N];
int main()
{
	scanf("%d%d", &n, &Q);
	int res = 0;
	int x, y, z;
	
	while (Q--)
	{
		scanf("%d%d%d", &x, &y, &z);
		if (++a[x][y] == n)res++;
		if (++b[x][z] == n)res++;
		if (++c[y][z]== n)res++;
			printf("%d\n", res);
	}
	return 0;
}
